<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

//use Illuminate\Support\Facades\Schema;

class AddField20231106 extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if (!Schema::hasColumn('tcm_book_chapters', 'describe')) {
            Schema::table('tcm_book_chapters', function (Blueprint $table) {
                $table->string('describe')->index()->nullable()->comment('介绍');
            });
        }

        if (!Schema::hasTable('tcm_aroma')) {
            Schema::create('tcm_aroma', function (Blueprint $table) {
                $table->id();
                $table->string('name')->index()->comment('名称');
                $table->string('class')->index()->nullable()->comment('香类');
                $table->string('img')->nullable()->comment('图片');
                $table->string('share_img')->nullable()->comment('分享图片');
                $table->string('pinyin')->nullable()->comment('拼音');
                $table->text('meridian')->nullable()->comment('性味功效');
                $table->text('taste')->nullable()->comment('功效');
                $table->string('origin_label')->index()->nullable()->comment('产地');
                $table->text('alias')->nullable()->comment('别名');
                $table->text('medicine_help')->nullable()->comment('用量用法');
                $table->text('clinical')->nullable()->comment('临床配伍');
                $table->text('history')->nullable()->comment('相关论述');
                $table->timestamps();
                $table->comment = '香';
            });
        }

        Schema::table('tcm_case_detail', function (Blueprint $table) {
            $table->index('doctor');
        });

        if (!Schema::hasTable('articles_drafts')) {
            Schema::create('articles_drafts', function (Blueprint $table) {
                $table->id();
                $table->integer('publish_id')->comment('文章发布人');
                $table->tinyInteger('type')->default(1)->comment('文章类型：1、热点快讯；2、新闻资讯');
                $table->string('title')->nullable()->comment('文章标题');
                $table->string('desc')->nullable()->comment('文章描述');
                $table->tinyInteger('file_type')->nullable()->comment('文章素材：1、图片；2、视频');
                $table->text('files')->nullable()->comment('文件');
                $table->text('video')->nullable()->comment('视频文件');
                $table->string('thum_img')->nullable()->comment('视频封面/文章缩略图');
                $table->text('content')->comment('文章内容');
                $table->tinyInteger('is_hot')->default(0)->comment('文章推荐：0、否；1、是');
                $table->tinyInteger('is_top')->default(0)->comment('文章顶置：0、否；1、是');
                $table->integer('first_relay_count')->default(0)->comment('初始转发数量');
                $table->string('first_fav_count')->default(0)->comment('初始点赞数');
                $table->integer('tag_id')->default(0)->comment('标签id');
                $table->string('mini_type')->comment('小程序类型');
                $table->dateTime('publish_date')->comment('发布时间');
                $table->tinyInteger('status')->default(0)->comment('发布状态 1-已发布 0-未发布');
                $table->timestamps();
                $table->index(['status', 'publish_date']);
                $table->comment = '文章草稿表';
            });
        }

        if (!Schema::hasTable('topics_drafts')) {
            Schema::create('topics_drafts', function (Blueprint $table) {
                $table->id();
                $table->integer('member_id')->comment('用户ID');
                $table->string('title')->comment('标题');
                $table->text('content')->nullable()->comment('内容');
                $table->text('files')->nullable()->comment('文件');
                $table->integer('relay_count')->default(0)->comment('转发数');
                $table->integer('fav_count')->default(0)->comment('点赞数');
                $table->string('is_hot')->default(0)->comment('推荐：0、否；1、是');
                $table->integer('tag_id')->default(0)->comment('标签id');
                $table->string('themes')->nullable()->comment('话题');
                $table->string('mini_type')->comment('小程序类型');
                $table->dateTime('publish_date')->comment('发布时间');
                $table->tinyInteger('status')->default(0)->comment('发布状态 1-已发布 0-未发布');
                $table->timestamps();
                $table->index(['status', 'publish_date']);
                $table->comment = '帖子草稿表';
            });
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
    }
}
